/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.moviedownloader.DbModel;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 *
 * @author patrik
 */
public class Format {
    
    private static final Map<String, Integer> ciselnik;
    
    static { 
        Map<String, Integer> tmp = new HashMap<>(); 
        
        tmp.put("film", 1);
        tmp.put("video film", 2);
        tmp.put("tv film", 3);
        tmp.put("tv seriál", 4);
        tmp.put("tv pořad", 5);
        tmp.put("divadelní záznam", 6);
        tmp.put("koncert", 7);
        tmp.put("studentský film", 8);
        tmp.put("amatérský film", 9);
        tmp.put("hudební videoklip", 10);
    
        ciselnik = Collections.unmodifiableMap(tmp);
    }
    
    public static Integer getType(String type){
        return ciselnik.get(type);
    }
    
    private final Integer value;
    
    public Format(String movieType){
        value = getType(movieType);
    }
    
    public Format(Integer type){
        value = type;
    }
    
    public Integer getValue(){
        return this.value;
    }
    
    @Override
    public String toString(){
        for(String str : ciselnik.keySet()){
            if(ciselnik.get(str) == value){
                return str;
            }
        }
        return null;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + Objects.hashCode(this.value);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Format other = (Format) obj;
        if (!Objects.equals(this.value, other.value)) {
            return false;
        }
        return true;
    }
    
    
    
    
    
}
